<?php

declare(strict_types=1);

/**
 * @Author:     Frank
 * @contact     frank_hhm@163.com
 * @Date:       2022-11-23 13:57:43
 * @Last Modified time: 2023-01-12 15:48:20
 */

namespace app\common\services\system;

use app\common\dao\system\AddonDao;

use frank\base\BaseService;
use frank\exception\CommonException;

/**
 * Class AddonService
 */
class AddonService extends BaseService
{

    /**
     * AddonService constructor.
     * @param AddonDao $dao
     */
    public function __construct(AddonDao $dao)
    {
        $this->dao = $dao;
    }

    public function getDetail($filter)
    {
        $detail = $this->dao->detail($filter);
        if (!$detail) {
            throw new CommonException('数据不存在');
        }
        return $detail->toArray();
    }

    public function getItem($name)
    {
        $detail =$this->dao->detail(['addon_name'=>$name]);
        if (!$detail) {
            throw new CommonException('数据不存在');
        }
        return $detail->toArray();
    }

    public function getSelectList($where)
    {
        $list = $this->dao->getAddonSelect($where);
        return $list;
    }
}